const FileUtils = imports.misc.fileUtils;
const Main = imports.ui.main;
+const SEARCH_PROVIDERS_SCHEMA = 'org.gnome.desktop.search-providers';
+
// Not currently referenced by the search API, but
// this enumeration can be useful for provider
// implementations.
this._searchPage = this._addPage(this._searchResults.actor, this._entry,
_("Search"), 'edit-find-symbolic');
+ this._searchSettings = new Gio.Settings({ schema: Search.SEARCH_PROVIDERS_SCHEMA });
+ this._searchSettings.connect('changed::disabled', Lang.bind(this, this._reloadRemoteProviders));
+
// Default search providers
// Wanda comes obviously first
this.addSearchProvider(new Wanda.WandaSearchProvider());
this._showPage(this._searchPage);
},
+ _shouldUseSearchProvider: function(provider) {
+ if (!provider.isRemoteProvider)
+ return true;
+
+ let appId = provider.appInfo.get_id();
+ let disable = this._searchSettings.get_strv('disabled');
+ return disable.indexOf(appId) == -1;
+ },
+
+ _reloadRemoteProviders: function() {
+ // removeSearchProvider() modifies the provider list we iterate on,
+ // so make a copy first
+ let remoteProviders = this._searchSystem.getRemoteProviders().slice(0);
+
+ remoteProviders.forEach(Lang.bind(this, this.removeSearchProvider));
+ RemoteSearch.loadRemoteSearchProviders(Lang.bind(this, this.addSearchProvider));
+ },
+
addSearchProvider: function(provider) {
+ if (!this._shouldUseSearchProvider(provider))
+ return;
+
this._searchSystem.registerProvider(provider);
this._searchResults.createProviderMeta(provider);
},